package com.example.jmxdemo.jmx;

import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Component;

/**
 * Spring Boot 中注册 MBean 通常会使用 @ManagedResource 和 @ManagedAttribute 注解来增强 MBean 的管理能力。
 *
 */
@Component
@ManagedResource(objectName = "com.example.jmxdemo.jmx:type=WelcomeConfig2")
public class WelcomeConfig2 implements WelcomeConfigMBean {

    private String content;

    @ManagedAttribute(description = "获取content")
    @Override
    public String getContent() {
        return content;
    }

    @ManagedAttribute(description = "设置content")
    @Override
    public void setContent(String content) {
        this.content = content;
    }

    @Override
    @ManagedOperation(description = "打印 hello")
    public void sayHello() {
        System.out.println("hello........");
    }

}
